<?php
require_once('../../global.php');
require_once BASE_DATA_PATH.'/vendors/alipay/AopClient.php';

$log_name = BASE_DATA_PATH.'/log/ali/'.date('Y-m-d').'.log';
$log_arr = array();
foreach ($_POST as $k => $v) {
    $log_arr[] = "$k=$v";
}
$log_data = implode("\r\n", array(
    '[支付宝支付回调]['.date('Y-m-d H:i:s').']',
    implode('&', $log_arr),
    '',
));
file_put_contents($log_name, $log_data, FILE_APPEND | LOCK_EX);

$aop = new AopClient();
//$aop->alipayrsaPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAptDyV0pRbSn2A33coQOBhzNIA29hgllWsLxDuai8uDuKxQ4tDpkakqSAu7Ru4fRFrXupCXxLPYFLi9sj3E6q0TjpxvfvWDYbx1iVNAqQXTNwx06ibxSsljTKePRevaVfwFAYSxyGhw7zEbu9YBAQuPo7ER48dWPsVgvgmBu0DEM0ZmrzT5NKnrROiFAKOwruwmQPxEDmhP4fc5ql41sTD+MfPEQPOWi6oTQxys20JhHK7kCwiMaKraaDFJi8zPrBxfXaXV92N8AGzWBodsFLRTJfAscGjhncYYKuygDma7yJS0CEt0gqKz0CgIQvGT43KHdPpeNavAYz1BDs6jDnjwIDAQAB';//请填写支付宝公钥,一行字符串
$aop->alipayrsaPublicKey   = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAitkV3HWbV9DUqDRPncMnwc0J4zFehoaWzeMtD2ktpMXO/EqcETgmL62hAdKzfFBDuRQ4pOovlFCXPV5PBRwLdcJL3XXdDnem1cPt4dfbAlpfhi+Q31Fkkv97rV56SRIkbBVIRx4PMVr8+Xbk0KPzF+TlxJrCFgxok2fwO7d2izdefH2BR0UMJ7q8r3cllMe7LwTy6tFwa0LnUap0liBRLTBGuU5lNIQTtnjxjjOkfHJ9GpjnHsmbecFADsFPj2sruDr+lT86QBqVfiAs6KBiTYgV+zyW95uBSWD14+jhG7OAZQvEiPsri4ZXiAViSDBRg/KR2DAdOvCu8Ek0mINFLQIDAQAB';
$flag = $aop->rsaCheckV1($_POST, null, 'RSA2');
file_put_contents($log_name, '验证签名结果:'.intval($flag)."\r\n\r\n", FILE_APPEND | LOCK_EX);
if ($flag === true) {
    if (isset($_POST['trade_status']) && $_POST['trade_status'] === 'TRADE_SUCCESS') {
        //启用系统框架
        $_GET['act'] = 'store_notify';
        $_GET['op'] = 'alipay';
        require_once(dirname(__FILE__) . '/../index.php');
    }
}

